<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <?php include 'inc/head.php'; ?>
</head>

<body>
  <?php include 'inc/header.php'; ?>

  <div class="container">
    <table class="table table-sm table-bordered table-hover">
      <thead class="bg-light">
        <tr>
          <th>插件名称</th>
          <th>调用函数</th>
          <th>操作</th>
        </tr>
      </thead>
      <tbody>
        <?php
        if (!empty($res)) {
          foreach ($res as $key => $row) {
            echo '<tr><td>' . $row['a_name'] . '</td><td>' . $row['a_func'] . '</td><td><a href="' . M('admin', 'addon', 'edit', $key) . '">编辑</a> <a href="' . M('admin', 'addon', 'del', $key) . '" onclick="return confirm(\'确认要删除吗？\')">删除</a></td></tr>';
          }
        }
        ?>
      </tbody>
    </table>

    <?php
    echo form_create(
      [
        'action' => M('admin', 'addon', 'add')
      ],
      [
        ['type' => 'text', 'label' => '名称', 'key' => 'a_name', 'required' => 'required'],
        ['type' => 'text', 'label' => '调用函数', 'key' => 'a_func', 'required' => 'required'],
        ['type' => 'textarea', 'label' => '描述', 'key' => 'a_desc'],
        ['type' => 'select', 'label' => '状态', 'key' => 'a_enable', 'value' => [['label' => '生效', 'value' => 1], ['label' => '失效', 'value' => 0]]],
        ['type' => 'submit', 'label' => '提交', 'key' => 'save']
      ],
      ['插件新增']
    );
    ?>

  </div>

  <?php include 'inc/footer.php'; ?>

</body>

</html>